<?php
/**
 * Created by PhpStorm.
 * User: shenyl
 * Date: 2019/2/27
 * Time: 15:56
 */
namespace app\api\model\user;

use think\Model;
use think\Db;
class UserPurseModel extends Model{

    /**
     * 查询是否存在未支付订单
     */
    public static function getUserPurseAmount($uid){
        $income = db('user_purse')->where([
            'uid' => $uid,
            'status' => [1,3]
        ])->sum('amount');
        $payment = db('user_purse')->where([
            'uid' => $uid,
            'status' => [2]
        ])->sum('amount');
        return intval($income) - intval($payment);
    }

}